package com.appwoo.android.component;

import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class AsyncImageLoader
{
  private static final String TAG = "AsyncImageLoader";
  private Map<String, SoftReference<Drawable>> imageCache = new HashMap();

  public Drawable loadDrawable(final String paramString, final ImageCallback paramImageCallback)
  {
    if (this.imageCache.containsKey(paramString))
    {
      SoftReference localSoftReference = (SoftReference)this.imageCache.get(paramString);
      if (localSoftReference.get() != null)
        return (Drawable)localSoftReference.get();
    }
    new Thread()
    {
      public void run()
      {
        Drawable localDrawable = AsyncImageLoader.this.loadImageFromUrl(paramString);
        AsyncImageLoader.this.imageCache.put(paramString, new SoftReference(localDrawable));
        this.val$handler.sendMessage(this.val$handler.obtainMessage(0, localDrawable));
      }
    }
    .start();
    return null;
  }

  protected Drawable loadImageFromUrl(String paramString)
  {
    try
    {
      Drawable localDrawable = Drawable.createFromStream((InputStream)new URL(paramString).getContent(), "image");
      return localDrawable;
    }
    catch (MalformedURLException localMalformedURLException)
    {
      Log.e("AsyncImageLoader", localMalformedURLException.getMessage());
      return null;
    }
    catch (IOException localIOException)
    {
      Log.e("AsyncImageLoader", localIOException.getMessage());
    }
    return null;
  }

  public static abstract interface ImageCallback
  {
    public abstract void imageLoaded(Drawable paramDrawable, String paramString);
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.android.component.AsyncImageLoader
 * JD-Core Version:    0.6.2
 */